<!-- TODO -->
<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
                <el-form-item label="用户ID">
                    <el-input
                            class="w-[150px]"
                            v-model="queryParams.uuid"
                            placeholder="请输入用户ID"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item label="用户昵称/手机号">
                    <el-input
                            class="w-[280px]"
                            v-model="queryParams.user_keyword"
                            placeholder="请输入用户昵称/手机号"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item label="提货人姓名">
                    <el-input
                            class="w-[280px]"
                            v-model="queryParams.name"
                            placeholder="请输入提货人姓名"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item label="提货人手机号">
                    <el-input
                            class="w-[280px]"
                            v-model="queryParams.name"
                            placeholder="请输入提货人手机号"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table size="large" class="mt-[14px]" :data="pager.lists">
                <el-table-column label="用户ID /  昵称" prop="name" min-width="180">
                    <template #default="{ row }">
                        {{ row.uuid }} /  {{ row.nickname }}
                    </template>
                </el-table-column>
                <el-table-column label="姓名" prop="name"  min-width="150">
                    <template #default="{ row }">
                        {{ row.username }}
                    </template>
                </el-table-column>
                <el-table-column label="手机号" prop="phone"  min-width="100">
                    <template #default="{ row }">
                        {{ row.phone }}
                    </template>
                </el-table-column>
                <el-table-column label="省份 / 市 / 区" prop="name"  min-width="180">
                    <template #default="{ row }">
                        {{ row.province }} / {{ row.city }} / {{ row.area }}
                    </template>
                </el-table-column>
                <el-table-column label="详细地址" prop="name"  min-width="150">
                    <template #default="{ row }">
                        {{ row.address }}
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="name"  min-width="150">
                    <template #default="{ row }">
                        {{ row.created_at }}
                    </template>
                </el-table-column>
                <el-table-column label="操作" fixed="right" min-width="160">
                    <template #default="{ row }">
                        <el-button type="primary" @click="handleEdit(row)"> 编辑 </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 分页 -->
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
    </div>
</template>

<script lang="ts" setup>
import { getUserAddressList, addressEdit } from '@/api/consumer'
import { usePaging } from '@/hooks/usePaging'
import { UserRankList } from '@/api/user'
import EditPopup from './edit.vue'
// import feedback from '@/utils/feedback'

const queryParams = reactive({
    uuid: '',
    user_keyword: '',
    name: '',
    phone: '',
});


const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: getUserAddressList
});

getLists();

const editRef = shallowRef<InstanceType<typeof EditPopup>>();
const showEdit = ref(false)

const handleEdit = async (data: any) => {
    showEdit.value = true;
    await nextTick();
    editRef.value?.open('edit');
    editRef.value?.getDetail(data)
}

</script>
<style lang="scss" scope>
//TODO
.el-alert--warning.is-light {
    background-color: rgba(246, 248, 255, 1);
    color: rgba(64, 115, 250, 1);
}
</style>
